/**
 * 公共基础接口
 */
import request from "@/utils/request"
// import { R } from './types/common'
import { ILoginPayload, ILoginResponse } from './types/common'

export const getLoginInfo = () => {
  // return request.get<R>('/api/login/info')
  return request({
    method: 'get',
    url: '/api/login/info'
  })
}

export const getCaptcha = () => {
  // return request.get<R<Blob>>('/api/captcha_pro', {
  //   responseType: 'blob' // 请求获取图片数据
  // })
  return request<Blob>({
    method: 'get',
    url: '/api/captcha_pro',
    params: {
      stamp: Date.now()
    },
    responseType: 'blob' // 请求获取图片数据
  })
}

export const login = (data: ILoginPayload) => {
  return request<ILoginResponse>({
    method: 'post',
    url: '/api/login',
    data
  })
}

export const logout = () => {
  return request({
    method: 'get',
    url: '/api/setting/admin/logout',
  })
}
